package org.example.controller;

import jakarta.annotation.Resource;
import org.example.entity.CommonResult;
import org.example.entity.Food;
import org.example.service.FoodService;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RefreshScope
public class FoodController {
    @Resource
    private FoodService foodService;
    //原接口FoodController/listFoodByBusinessId
    @GetMapping("/FoodController/listFoodByBusinessId/{id}")
    public CommonResult<List> findAllByBusinessid(@PathVariable("id") Integer id){
        List<Food> foods =  foodService.findAllByBusinessId(id);
        return new CommonResult<>(200,"返回对应商家id的食品列表（22001）",foods);
    }
    @GetMapping("/FoodController/findFoodById/{id}")
    public CommonResult<Food> findFoodById(@PathVariable("id") Integer id){
        Food foods =  foodService.findByFoodId(id);
        return new CommonResult<>(200,"返回对应商家id的食品列表（22001）",foods);
    }

}
